-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RTNR] Pass binary data to RTNR #5544
[RTNR] Pass binary data to RTNR #5544
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need more detail in commit message.
switch (cdata->data->type) { | ||
case SOF_RTNR_CONFIG: | ||
comp_dbg(dev, "rtnr_set_bin_data(): SOF_RTNR_CONFIG"); | ||
ret = comp_data_blob_set_cmd(cd->model_handler, cdata); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lgirdwood can two parameters be passed at the same time? Just wondering if the same model handler can be reused or if they have to be separate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently the model_handler is used for settings only( sample rate/ on&off ). For other data we would like to modify the internal data in RTNR directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsarha is updated this API at, @jsarha can we support multiple large blobs per module/component ?
@MingJenTai I think the data would have to be serialized so that we only send one at a time from the host, @jsarha pls correct me if I'm wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It won't work as such, since the handler only maintains one blob per com_data_blob_handler. I think the easiest would adding multiple handlers to the comp_data, one for each blob, and and select the correct one based on component specific type.
src/audio/rtnr/rtnr.c
Outdated
comp_dbg(dev, "rtnr_set_bin_data(): SOF_RTNR_DATA_2"); | ||
ret = RTKMA_API_Set_Data_2(cd->rtk_agl, | ||
cdata->data->data, | ||
cdata->msg_index, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
src/audio/rtnr/rtnr.c
Outdated
@@ -46,6 +50,16 @@ struct rtnr_func_map { | |||
rtnr_func func; /**< processing function */ | |||
}; | |||
|
|||
|
|||
struct param_data_hdr { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this an additional header? I am confused why you need this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes there will be different types of binary data for RTNR. We use this as an identification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isnt this just a duplicate of our existing header?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not exactly. The additional magic number could tell us if the data is actually created by Realtek. And with the type identifier we could call different API for different data type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, but a type does not define the magic inside it. Also why do you need the additional magic? Can't you tell by type
field
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The magic number will be checked inside RTNR library for an additional verification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lgirdwood thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cujomalainey param_data_hdr has been removed from wrapper code. It won't be used there. : )
658e003
to
ed72088
Compare
Just force pushed a commit to reflect the change of the interface of RTKMA_API_Prepare(). A new build of RTNR library will be provided next week. Thanks. |
I am of the opinion we should reject this PR in favour of the new single blob mode in #5509 which seems to be safer as it's tied to component state and fuzzable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the data_1/2 usage is confusing, can we clear this up. Thanks
unsigned int msg_index, | ||
unsigned int num_elms, | ||
unsigned int elems_remaining); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When should we use 1 and when should we use 2 ? can the be better named so users can understand the usage better. I would also put some comments explaining the difference and usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review. We'll combine those 2 APIs into 1 to avoid confusion.
Another question is what's the best practice to send binary configuration file to sof component during system startup? The config is about 2KB, and should only be set once.
We've been using sof-ctl which works well, but the same configuration will be sent every time before recording. Besides, using sof-ctl might not be a proper way for final product.
We've also tried using cset-tlv to send config just like the control blobs for the UI. However the config is much larger than control blobs and I have no success during my experiments. Is there file size limit for this?
Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just force-pushed a commit to simplify the Set_Data API.
There could be different types of the data, but yes they should be handled internally in library.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could have a the config data as a static data block as part of the RTNT. This would be build into the DATA section and could be used by default ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes currently there is a default config stored in the static table inside the firmware. The proposed method provides a way to overwrite the default config so that we don't have to re-build firmware each time when a new config is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using my PR #5509 you could use the new comp_data_blob_handler_new_ext() with single_blob = true and tap into alloc() and free() callbacks to return always the pointer to the static buffer (and return an error if the requested size is bigger than the buffer).
With this approach you should keep using the comp_data_blob_handler and friends mostly the way the other components do. The IPC fragment aggregating would be handled by data_blob.c functions. Just before processing call you should check with comp_is_current_data_blob_valid() if the configuration buffer is currently valid, or if it is in the middle of an update.
This commit allows binary data to be passed to RTNR. There could be different types of the data, and those data will update the internal data of RTNR directly. Signed-off-by: Ming Jen Tai <[email protected]>
ed72088
to
a8f3a89
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsarha any comments for the blob loader ?
@@ -26,6 +26,7 @@ struct sof_rtnr_config { | |||
uint32_t reserved[4]; | |||
|
|||
struct sof_rtnr_params params; | |||
int32_t data[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wont you need a size here to tell client code how big data[] is ? or maybe this in fully handled in blob API @jsarha please comment here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The data is with variable length. Actual size is stored in the size flag.
int ret = 0; | ||
|
||
switch (cdata->cmd) { | ||
case SOF_CTRL_CMD_BINARY: | ||
comp_info(dev, "rtnr_cmd_set_data(), SOF_CTRL_CMD_BINARY"); | ||
ret = comp_data_blob_set_cmd(cd->model_handler, cdata); | ||
ret = rtnr_set_bin_data(dev, cdata); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you stop using comp_data_blob_set_cmd() for some cases and implement the message handling for those your self, you should do the same thing symmetrically for comp_data_blob_get_cmd(). One alternative would not to use the comp_data_blob_handler at all and write all message fragment handling your self.
unsigned int msg_index, | ||
unsigned int num_elms, | ||
unsigned int elems_remaining); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using my PR #5509 you could use the new comp_data_blob_handler_new_ext() with single_blob = true and tap into alloc() and free() callbacks to return always the pointer to the static buffer (and return an error if the requested size is bigger than the buffer).
With this approach you should keep using the comp_data_blob_handler and friends mostly the way the other components do. The IPC fragment aggregating would be handled by data_blob.c functions. Just before processing call you should check with comp_is_current_data_blob_valid() if the configuration buffer is currently valid, or if it is in the middle of an update.
switch (cdata->data->type) { | ||
case SOF_RTNR_CONFIG: | ||
comp_dbg(dev, "rtnr_set_bin_data(): SOF_RTNR_CONFIG"); | ||
ret = comp_data_blob_set_cmd(cd->model_handler, cdata); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It won't work as such, since the handler only maintains one blob per com_data_blob_handler. I think the easiest would adding multiple handlers to the comp_data, one for each blob, and and select the correct one based on component specific type.
@MingJenTai any update ? |
Can one of the admins verify this patch? |
We haven't check #5509 yet. Will make the required modifications if necessary. Thanks! |
please rebase this PR or close it as it conflicts with main. |
Need to be refined. Close now. |
This PR allows the host to pass binary data to RTNR